<?php 
error_reporting(E_ERROR);
session_start();
require_once('constants.php');
require_once('functions.php');
include('classes/userClass.php');



#conect to shop database	
$shopObj = new mysqlClass();

	if(isset($_POST['make_cities'])){
		$params = array($_POST['make_cities']);
		$data = $shopObj->fetch_result("SELECT * FROM cities WHERE county_id=?",$params);
		$tosend = '<select id="city" name="city" class="select2" data-placeholder="Click to Choose...">';
		foreach ($data as $key => $value) {
			$tosend .= "<option value ='{$value['id']}'>{$value['name']}</option>";
		}
		$$tosend .= "</select>";
		echo $tosend;
	}
	if(isset($_POST['save_company'])){
			
            if($_POST['active']==1){
                $active=1;
            }else{
                $active=0;
            }
							
			$params = array($_POST['name'],$active,$_POST['city'],$_POST['state'],$_POST['business_type']);
		    
		    $shopObj->execute_query("UPDATE user_shops SET  name =?, active=?,city_id=?,county_id=?,business_type=? WHERE url='{$_POST['company_url']}'  ",$params);
	}
?>